﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crosland.Automotriz.Data.Dao.Linq;
using Crosland.Automotriz.Core;
using System.Data;
using Crosland.Automotriz.Logic.ControlExeption;

namespace Crosland.Automotriz.Logic.Linq
{
    public class clsT_Man_ArticuloLogic
    {
        clsT_Man_ArticuloDAO clst_man_articulodao = new clsT_Man_ArticuloDAO();

        public List<T_MAN_ARTICULO> listarArticulos()
        {
            return clst_man_articulodao.listarArticulos();
        }


        public bool Insertar(T_MAN_ARTICULO Obj)
        {
            try
            {
                return clst_man_articulodao.Insertar(Obj); 
            }
            catch (EntityException sqlEx)
            {

                throw new RunException("ERROR AL INSERTAR EN T_MAN_ARTICULO", sqlEx);
            }
            catch (Exception ex)
            {
                throw new RunException("ERROR EN LA APLICACION POR FAVOR CONSULTE: ", ex);
            }     
        
        }

        public bool Modificar(T_MAN_ARTICULO obj)
        {
            return clst_man_articulodao.Modificar(obj);
        }

        public bool Eliminar(T_MAN_SISTEMA obj)
        {
            return clst_man_articulodao.Eliminar(obj);
        }
        public List<T_MAN_ARTICULO> listarArticulosLike(string cod_material, string nom_material_ingles) {

            return clst_man_articulodao.listarArticulosLike(cod_material, nom_material_ingles);
        
        }


        public List<T_MAN_ARTICULO> list_consulta(string cod_material)
        {

            
            try
            {
                if (clst_man_articulodao.list_consulta(cod_material) == null)
                {
                    throw new Crosland.Automotriz.Logic.ControlExeption.DataException("No hay datos en la lista");
                }
                return clst_man_articulodao.list_consulta(cod_material);
            }
            catch (Exception e)
            {
                throw new RunException("ERROR EN LA LISTA  T_MAN_ARTICULO", e);
            }

        }


        public IEnumerable<Object> listarT_Man_articulo_likexmodelo(string des_material)
        {

            return clst_man_articulodao.listarT_Man_articulo_like(des_material);
        }

    }
}
